Fix <DataTable> may duplicate ids in its selection state
#11047
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When using infinite lists or paginated lists with bulk selection, a bug caused duplicate record IDs in the selection array in specific scenarios.
This was caused by an operator precedence error in the filter logic within
SelectPageCheckbox.tsx. WhenisRowSelectablewasundefined(the default case), the boolean expression was incorrectly evaluated, causing already selected items to bypass the duplicate check.Solution
SelectPageCheckbox.tsx:!selectedIds.includes(record.id)) is always respectedisRowSelectablebehaviorAdded unit tests in
DataTable.spec.tsxAdded E2E tests in
list.cy.jsBoth confirm correct behavior for:
How To Test
make test- Unit tests: 2594 passedmake test-e2e- E2E tests: 101 passedAll tests pass successfully.
Additional Checks
masterfor a bugfixDataTable.spec.tsx)list.cy.js)Notes
!selectedIds.includes(record.id) && isRowSelectable ? isRowSelectable(record) : trueincorrectly evaluated whenisRowSelectableisundefined).master(confirmed unrelated to this change).